package permission

import (
	"context"
	"net/http"
	"private-domain-overseas-service/admin/business/api/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AdminRouteIsExistLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// NewAdminRouteIsExistLogic - 判断路由是否存在接口
func NewAdminRouteIsExistLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminRouteIsExistLogic {
	return &AdminRouteIsExistLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// AdminRouteIsExist - 判断路由是否存在接口
func (l *AdminRouteIsExistLogic) AdminRouteIsExist(r *http.Request) (resp bool, err error) {
	// 如果获取首页就返回false，拒绝获取，只能从自己有点路由中获取首页
	return r.URL.Query().Get("routeName") != "home", nil
}
